﻿using System;

namespace StoCombatLogHUD.GameStates
{
	/// <summary>
	/// Manages this games states.
	/// </summary>
	public class GameStateManager
	{
		/// <summary>
		/// Gets or sets the game.
		/// </summary>
		/// <value>
		/// The game.
		/// </value>
		private Main Game { get; set; }

		/// <summary>
		/// The game state lock object.
		/// </summary>
		private readonly object gameStateLockObject = new object();

		/// <summary>
		/// Initializes a new instance of the <see cref="GameStateManager"/> class.
		/// </summary>
		/// <param name="game">The game.</param>
		public GameStateManager(Main game)
		{
			Game = game;
		}

		/// <summary>
		/// Displays the summary.
		/// </summary>
		public void DisplaySummary()
		{
			lock (gameStateLockObject)
			{
				var summaryDisplayState = new SummaryDisplayState(Game);
				Game.GameStateMgr.SwitchState(summaryDisplayState);
			}
		}

		/// <summary>
		/// Displays the details.
		/// </summary>
		/// <param name="playerName">Name of the player.</param>
		public void DisplayDetails(string playerName)
		{
			lock (gameStateLockObject)
			{
				var detailDisplayState = new DetailDisplayState(Game, playerName);
				Game.GameStateMgr.SwitchState(detailDisplayState);
			}
		}

		/// <summary>
		/// Displays an exception.
		/// </summary>
		/// <param name="exception">The exception.</param>
		/// <exception cref="System.NotImplementedException"></exception>
		public void DisplayException(string exception)
		{
			lock (gameStateLockObject)
			{
				var exceptionState = new ExceptionState(Game, exception);
				Game.GameStateMgr.SwitchState(exceptionState);
			}
		}
	}
}
